<?php
/**
 * Created by PhpStorm.
 * User: acker
 * Date: 21-06-08
 * Time: 下午6:25
 */

namespace App\Models\yb;
use App\Models\AdminUserModel;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\DefaultDatetimeFormat;


class NetworkGoodsModel extends Model
{
    use DefaultDatetimeFormat;

    use SoftDeletes;

    /**
     *
     *计量单位
     * @var string
     */
    protected $table = 'yb_network_goods';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'id';



    /**
     * 该模型是否被自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = true;

    protected $appends = [
        'goods_audit_records',
        'goods_reason'
    ];

    /**
     * @return mixed
     */
    public function getGoodsAuditRecordsAttribute(){
        return '审核记录';
    }
    /**
     * @return mixed
     */
    public function getGoodsReasonAttribute(){
        return '下架原因';
    }



    /**
     * @return mixed
     */
    public function Network()
    {
        return $this->hasOne(AdminUserModel::class,'id','network_id');
    }

    /**
     * @return mixed
     */
    public function Goods()
    {
        return $this->hasOne(GoodsModel::class,'id','goods_id');
    }

    /**
     * @return mixed
     */
    public function NetworkGoodsReview()
    {
        return $this->hasMany(NetworkGoodsReviewModel::class,'network_goods_id','id');
    }


    /**
     * @return mixed
     */
    public function NetworkGoodsReason()
    {
        return $this->hasMany(NetworkGoodsReasonModel::class,'network_goods_id','id');
    }



}
